package com.ruoyi.system.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SafetyExaminationExaminationpaper;
import com.ruoyi.system.service.ISafetyExaminationExaminationpaperService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 考试试卷Controller
 * 
 * @author ruoyi
 * @date 2021-04-07
 */
@RestController
@RequestMapping("/system/examinationexaminationpaper")
public class SafetyExaminationExaminationpaperController extends BaseController
{
    @Autowired
    private ISafetyExaminationExaminationpaperService safetyExaminationExaminationpaperService;

    /**
     * 查询考试试卷列表
     */
    @PreAuthorize("@ss.hasPermi('system:examinationexaminationpaper:list')")
    @GetMapping("/list")
    public TableDataInfo list(SafetyExaminationExaminationpaper safetyExaminationExaminationpaper)
    {
        startPage();
        List<SafetyExaminationExaminationpaper> list = safetyExaminationExaminationpaperService.selectSafetyExaminationExaminationpaperList(safetyExaminationExaminationpaper);
        return getDataTable(list);
    }

    /**
     * 导出考试试卷列表
     */
    @PreAuthorize("@ss.hasPermi('system:examinationexaminationpaper:export')")
    @Log(title = "考试试卷", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SafetyExaminationExaminationpaper safetyExaminationExaminationpaper)
    {
        List<SafetyExaminationExaminationpaper> list = safetyExaminationExaminationpaperService.selectSafetyExaminationExaminationpaperList(safetyExaminationExaminationpaper);
        ExcelUtil<SafetyExaminationExaminationpaper> util = new ExcelUtil<SafetyExaminationExaminationpaper>(SafetyExaminationExaminationpaper.class);
        return util.exportExcel(list, "examinationexaminationpaper");
    }

    /**
     * 获取考试试卷详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:examinationexaminationpaper:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(safetyExaminationExaminationpaperService.selectSafetyExaminationExaminationpaperById(id));
    }

    /**
     * 新增考试试卷
     */
    @PreAuthorize("@ss.hasPermi('system:examinationexaminationpaper:add')")
    @Log(title = "考试试卷", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SafetyExaminationExaminationpaper safetyExaminationExaminationpaper)
    {
        return toAjax(safetyExaminationExaminationpaperService.insertSafetyExaminationExaminationpaper(safetyExaminationExaminationpaper));
    }

    /**
     * 修改考试试卷
     */
    @PreAuthorize("@ss.hasPermi('system:examinationexaminationpaper:edit')")
    @Log(title = "考试试卷", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    public AjaxResult edit(@RequestBody SafetyExaminationExaminationpaper safetyExaminationExaminationpaper)
    {
        return toAjax(safetyExaminationExaminationpaperService.updateSafetyExaminationExaminationpaper(safetyExaminationExaminationpaper));
    }

    /**
     * 删除考试试卷
     */
    @PreAuthorize("@ss.hasPermi('system:examinationexaminationpaper:remove')")
    @Log(title = "考试试卷", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(safetyExaminationExaminationpaperService.deleteSafetyExaminationExaminationpaperByIds(ids));
    }
}
